package com.jp.knowledge.my.business;

import com.jp.knowledge.R;
import com.jp.knowledge.my.model.ActiveDataModel;
import com.jp.knowledge.my.model.OptionSelectModel;

import java.util.ArrayList;
import java.util.List;

/**
 * @author gzejia 978862664@qq.com
 */
public class MyVipBusiness {

    /**
     * @param gradValue 用户当前积分
     * @return 积分图标集合
     */
    public List<OptionSelectModel> getGradItems(int gradValue) {
        int[] images = {
                R.mipmap.ic_my_message,
                R.mipmap.ic_my_message,
                R.mipmap.ic_my_message};
        String[] values = {"0", "1000", "5000"};
        List<OptionSelectModel> models = new ArrayList<>();

        for (int i = 0, k = images.length; i < k; i++) {
            OptionSelectModel model = new OptionSelectModel();
            model.mImage = images[i];
            model.mContent = values[i];
            model.isSelect = Integer.parseInt(values[i]) <= gradValue;
            models.add(model);
        }
        return models;
    }

    /**
     * 个人特权数量限定
     */
    public static final int FRANCHISE_PERSONAL_SIZE = 8;

    /**
     * @param yourIndexList 自定义特权数组，必需保持对应关系，<0 代表N
     * @return 特权内容
     */
    public List<ActiveDataModel> getFranchisePersonalData(List<Integer> yourIndexList) {
        List<ActiveDataModel> models = new ArrayList<>();
        String[] names = {"主题数", "订阅数", "应用体验数", "竞品报告书", "解决方案数",
                "点评报告数", "产品学习包", "产品微信群"};
        String[] units = {"个", "个", "个", "个", "个", "个", "套", "个"};

        if (yourIndexList.size() != names.length || yourIndexList.size() != FRANCHISE_PERSONAL_SIZE
                || names.length != units.length) {
            throw new IndexOutOfBoundsException("用户特权数据与定义数据大小不符");
        } else {
            for (int i = 0, k = names.length; i < k; i++) {
                ActiveDataModel model = new ActiveDataModel();
                model.mName = names[i];
                model.mUnit = units[i];
                model.mIndex = yourIndexList.get(i);
                models.add(model);
            }
        }
        return models;
    }

    /**
     * 组织特权数量限定
     */
    public static final int FRANCHISE_ORGANIZE_SIZE = 8;

    /**
     * @param yourIndexList 自定义特权数组，必需保持对应关系，<0 代表N
     * @return 特权内容
     */
    public List<ActiveDataModel> getFranchiseOrganizeData(List<Integer> yourIndexList) {
        List<ActiveDataModel> models = new ArrayList<>();
        String[] names = {"产品上线数", "线下活动", "解决方案推荐", "公司推荐广告", "主题人工优化",
                "竞品报告编写", "解决方案编写", "专家导师指导"};
        String[] units = {"次", "次", "个", "次", "个", "个", "套", "次"};

        if (yourIndexList.size() != names.length || yourIndexList.size() != FRANCHISE_ORGANIZE_SIZE
                || names.length != units.length) {
            throw new IndexOutOfBoundsException("组织特权数据与定义数据大小不符");
        } else {
            for (int i = 0, k = names.length; i < k; i++) {
                ActiveDataModel model = new ActiveDataModel();
                model.mName = names[i];
                model.mUnit = units[i];
                model.mIndex = yourIndexList.get(i);
                models.add(model);
            }
        }
        return models;
    }
}
